/******************************************************************************
Copyright:
2009 Jens Collin (jens.collin@dinomin.com)

This file is part of Envox Decompiler.

Envox Decompiler is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Envox Decompiler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KitchenOS.  If not, see <http://www.gnu.org/licenses/>.

******************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;

namespace EnvoxDecompiler
{
    public sealed class Globals
    {
        private static Globals instance = new Globals();

        public static Globals Instance
        {
            get
            {
                return instance;
            }
        }


        /// <summary>
        /// Ripper of information from resource. Saxed from internet somewhere.
        /// </summary>
        /// <param name="resourceName"></param>
        /// <returns></returns>
		internal string GetFromResources(string resourceName)
		{
            Assembly assem = GetType().Assembly;   
			using( Stream stream = assem.GetManifestResourceStream(resourceName) )   
			{
				try      
				{ 
					using( StreamReader reader = new StreamReader(stream) )         
					{
						return reader.ReadToEnd();         
					}
				}     
				catch(Exception e)      
				{
					throw new Exception("Error retrieving from Resources. Tried '" 
						+ resourceName+"'\r\n"+e.ToString());      
				}
			}
		}        
        
        public string COPYRIGHTTEXT = "Copyright Jens A. Collin 2006-2011";
        
        public string PRODUCTNAME = "EnvoxDecompiler";

        public string WEBSITE = "http://code.google.com/p/envox-decompiler/";

        /// <summary>
        /// Name of company that owns the decompiler, for now the url to my page.
        /// </summary>
        public string COMPANYNAME = "public (GPL)";

        /// <summary>
        /// Returns major version number
        /// </summary>
        public string MAJORVERSION = "1.0";

        /// <summary>
        /// Complete version string "1.0 build 22"
        /// </summary>
        public string VERSION
        {
            get
            {
                string major = MAJORVERSION;
                string vers = GetFromResources("EnvoxDecompiler.EnvoxDecompiler.build_number.txt");
                return major + " Build " + vers.Trim();
            }
        }

    }
}
